//子项目展示js
var $dataTable;
function deleteSubProject(id) {
	if (id == null) {
		alert('id为空');
		return;
	}
	if (confirm('确定删除该项目吗?')) {
		var param = {};
		param.id = id;
		postContent("/subProject/delete", param, true, function(data) {
			if (data != null) {
				alert('删除成功!');
				$dataTable.ajax.reload();
			}
		});
	}
}

function showSubProject(id) {
	if (id == null) {
		alert('id为空');
	}
	var param = {};
	param.projectId = id;
	showContent('/view/subproject-show.html',param,allSubProjectInit);
}

function allSubProjectInit() {
	var projectId= $('#projectId').val();
	var param = {};
	param.projectId = projectId;
	if(projectId==null){
		$('#createSub').hide();
	}
	$dataTable = $('#option')
			.DataTable(
					getCommonPageParam(
							"/subProject/showPage",
							param,
							true,
							[ {
								"mData" : "shortName"
							}, {
								"mData" : "code"
							}, {
								"mData" : "collect"
							}, {
								"mData" : "rate"
							}, {
								"mData" : "interestTypeStr"
							}, {
								"mData" : "payTypeStr"
							}, {
								"mData" : "buyerlist"
							}, {
								"mData" : "buyercreate"
							}, {
								"mData" : "generate"
							}, {
								"mData" : "operation"
							} ],
							function(resp) {
								var data = resp.aaData;
								for (num in data) {
									var id = data[num].id;
									data[num].shortName = '<a href="#" onclick=modiSubProject('
											+ id 
											+ ')>'
											+ data[num].shortName
											+ '</a>';
									data[num].buyerlist = '<a href="#" onclick=showBuyer('+id+')>认购列表</a>';
									data[num].buyercreate = '<a href="#" onclick=createBuyer('+id+')>创建认购账号</a>';
									data[num].generate = '<a href="#" onclick=showTemplateGenerate('+id+',1)>生成</a>';
									data[num].operation = '<a href="#" onclick=deleteSubProject('
											+ id + ')>删除</a>';
								}
								return resp;
							}));
}